<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script type="text/javascript" src="<s:url value="/dwr/engine.js"/>"></script>
<script type='text/javascript' src='<s:url value="/dwr/interface/BankQuery.js"/>'></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.blockUI.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.validate.min.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/pwms.validate.js?v13" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>
	
	<!-- jQuery UI 插件 -->
	<link rel="stylesheet" href=<s:url value="/css/jquery.ui.all.css"/>>
	<script src=<s:url value="/js/ui/jquery.ui.core.js"/>></script>
	<script src=<s:url value="/js/ui/jquery.ui.widget.js"/>></script>
	<script src=<s:url value="/js/ui/jquery.ui.position.js"/>></script>
	<script src=<s:url value="/js/ui/jquery.ui.menu.js"/>></script>
	
	<script src=<s:url value="/js/ui/jquery.ui.autocomplete.js"/>></script>
	<link rel="stylesheet" href=<s:url value="/css/demos.css"/>>
	

<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">

	$(document).ready(function() {
		
		//验证商户号长度
		jQuery.validator.addMethod("sLength", function(value,element) {
			var length = value.length;
			if(length!=15){
				return this.optional(element) || false;
			}
			return this.optional(element) || true;
		}, "商户号长度为15");
		//验证终端号长度
		jQuery.validator.addMethod("tLength", function(value,element) {
			var length = value.length;
			if(length!=8){
				return this.optional(element) || false;
			}
			return this.optional(element) || true;
		}, "终端号长度为8");
		//验证金额
		jQuery.validator.addMethod("isMoney", function(value,element) {
			var reg= /^([1-9][\d]{0,9}|0)(\.[\d]{1,2})?$/;
			if(reg.test(value)){
				return this.optional(element) || true;
			}
			return this.optional(element) || false;
			}, "必须在0-9999999999.99之间，最多2位小数");
		
		$("#unpayMer").validate({
			debug : true,
			submitHandler : function(form) {
				$("#btnAdd").attr("disabled",true);
					form.submit();
			},
			rules : {
				"unPay.merchantNo":{required : true,sLength:true},
				"unPay.terminalNo":{required : true,tLength:true},
				"unPay.feeT1":{required : true,isMoney:true},
				"unPay.feeT1Top":{required : true,isMoney:true},
				"unPay.feeT0":{required : true,isMoney:true},
				"unPay.accountNo" : {required : true},
				"unPay.accountName":{required : true},
				"unPay.ylId":{required : true},
				"unPay.bankName":{required : true},
				"unPay.remark":{required : true}
			},
			messages : {
				"unPay.merchantNo":{required : "必填"},
				"unPay.terminalNo" : {required : "必填"},
				"unPay.feeT1":{required : "必填"},
				"unPay.feeT1Top":{required : "必填"},
				"unPay.feeT0":{required : "必填"},
				"unPay.accountNo":{required : "必填"},
				"unPay.accountName":{required : "必填"},
				"unPay.ylId":{required : "必填"},
				"unPay.bankName":{required : "必填"},
				"unPay.remark":{required : "必填"},
			},errorPlacement: function(error, element) { 
			    if ( element.is(":radio") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is(":checkbox") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is("input") ) {
			    	error.appendTo ( element.parent() ); 
			    }
			    else 
			        error.insertAfter(element); 
			} 

		});
		
	});
	
    $(function() {
  	  //加载银行
  	var bankMap = $("#bankListHidden").val();
  	var bankMapArray = bankMap.substring(1,bankMap.length-1).split(",");
  	/* alert(bankMapArray[0]+" "+bankMapArray[0].length); */
		$( "#tags" ).autocomplete({
			source: bankMapArray  ,select:function(event,ui){
				$("#aaa").val("");
				$("#bbb").val("");
				var optionValue = ui.item.value;
				if(optionValue){
					obtainSomeBank(optionValue);
				}
				
			}  
		});
  	
		$("#aaa").focus(function(){
		  	var optionValue = $.trim($("#tags").val());
		  	if(!optionValue){
		  		alert("请先在第一个输入框中输入银行后再选择输入支行");
		  	}
		  });
  	
    });	
		
  
  
      
	function obtainSomeBank(mvalue) {
		
		var valArray = mvalue.split("_");
		
		BankQuery.loadBankInfo($.trim(valArray[0]), function(objs) {
			var someBankNameArray = [];
			
			for(var i=0;i<objs.length;i++){
				
				someBankNameArray.push(objs[i].name);
			}
			$("#aaa").autocomplete({
				source : someBankNameArray,select:function(event,ui){
					var zhBankName = ui.item.value;
					for(var i=0;i<objs.length;i++){
						if(zhBankName == objs[i].name){
							$("#bbb").val(objs[i].code);
							break;
						}
					}
				}
			});
			

		});
	}

</script>



</head>

<body>
			<s:form id="unpayMer" action="/unpay/addUnpay.ct" method="post"  theme="simple"  >
				<table width="100%" class="tb" >
			        <tr class="tb-line">
			            <td class="tb-td" colspan="6">
				            <div class="tb-h2">POS收单运营管理平台</div>
					   	</td>
			        </tr>
	                <tr class="tb-line bg-gray">
			            <td class="tb-td" colspan="4">
			            		<div class="tb-h3">
			                		添加银联直连商户
			                	</div></td>
			        </tr>
					<tr class="tb-line">						     
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" >商户号：</div>
			            </td>
			            <td class="tb-td" >				            		
			                	<label class="tb-input-lengthen">
			                		<s:textfield maxLength="200" name="unPay.merchantNo"
									cssClass="queryWidth"></s:textfield>
								</label>
								<font color="red">*</font>
						</td>
						<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" >终端号：</div>
			            </td>
			            <td class="tb-td" >
			            		<label class="tb-input-lengthen">			             									
								<s:textfield maxLength="200" name="unPay.terminalNo"
									cssClass="queryWidth" ></s:textfield>
									</label>
									<font color="red">*</font>
						</td>
						</tr>
						<tr class="tb-line">				    						     
					    	<td align="right" class="tb-td" style="width:110px;">
					        	<div class="tb-h4" >T1手续费：</div>
				            </td>
				            <td class="tb-td" >				            		
				            			<label class="tb-input-lengthen">
				                		<s:textfield maxLength="200" name="unPay.feeT1"
										cssClass="queryWidth"></s:textfield>
										</label> %
										<font color="red">*</font>
							</td>
							<td align="right" class="tb-td" style="width:110px;">
					        	<div class="tb-h4" >T1封顶：</div>
				            </td>
				            <td class="tb-td" >				            		
				            			<label class="tb-input-lengthen">
				                		<s:textfield maxLength="200" name="unPay.feeT1Top"
										cssClass="queryWidth" ></s:textfield>
										</label> 元
										<font color="red">*</font>
							</td>
						</tr>
						<tr class="tb-line">					
					    	<td align="right" class="tb-td" style="width:110px;">
					        	<div class="tb-h4" >T0手续费：</div>
				            </td>
				            <td class="tb-td" >
				            		<label class="tb-input-lengthen">
				             		<s:textfield maxLength="200" name="unPay.feeT0"
										cssClass="queryWidth" ></s:textfield>
									</label> %
										<font color="red">*</font>
							</td>
							<td align="right" class="tb-td" style="width:110px;">
					        	<div class="tb-h4">结算帐号：</div>
				            </td>
				            <td class="tb-td" >
				            		<label class="tb-input-lengthen">
				             		<s:textfield maxLength="200" name="unPay.accountNo"
										cssClass="queryWidth" ></s:textfield>
									</label>
									<font color="red">*</font>
							</td>
						</tr>
					<tr class="tb-line">
				        <td align="right" class="tb-td" style="width:110px;">
					        	<div class="tb-h4" >结算账户名称：</div>
				            </td>
				            <td class="tb-td" >
				            		<label class="tb-input-lengthen">
				             		<s:textfield maxLength="200" name="unPay.accountName"
										cssClass="queryWidth" ></s:textfield>
									</label>
									<font color="red">*</font>
							</td>
							
						<td align="right" class="tb-td" style="width:110px;">
						        	<div class="tb-h4" >直连所属银行ID：</div>
					     		</td>
					            <td class="tb-td" >
					            		<label class="tb-input-lengthen">
					             		<s:textfield maxLength="200" name="unPay.ylId"
											cssClass="queryWidth" ></s:textfield>
										</label>
										<font color="red">*</font>
								</td>	
					
					</tr>
					<tr class="tb-line">
					
						 <td width="7%" style="min-width: 110px" align="right" class="tb-td"  >
                        	<div class="tb-h4">结算银行名称：</div>
                    	</td>
					            <td class="tb-td"   >
					            		
					             		 <span><input type="hidden" value="<s:property value="#request.bMapToList"/>" id="bankListHidden">
											<input id="tags" style="width:150px" placeholder="输入银行">-<input id="aaa" name="unPay.bankName"  placeholder="输入支行" style="width:250px"></span><code class="asterisk">*</code>
						
								</td>      		
						<td align="right" class="tb-td" style="width:110px;">
						        	<div class="tb-h4" id="title">联行号：</div>
					     		</td>
					            <td class="tb-td" >
					            		<label class="tb-input-lengthen">
                        					<s:textfield id="bbb" name="unPay.bankCode" maxLength="12" readonly="true" cssStyle="background-color:lightgray;"/>
                        				</label><code class="asterisk">*</code>
								</td>
								
						</tr>
						
					<tr class="tb-line">					
				    	<td align="right" class="tb-td" style="width:110px;">
				        	<div class="tb-h4" id="title">备注：</div>
			            </td>
			            <td class="tb-td" colspan="3" style="height:auto;line-height:auto;" >
			             	<label style="height:auto;line-height:auto;">
			             		<s:textarea rows="5" cssClass="someWidth" 
								name="unPay.remark" maxlength="200"  style="height: 102px; resize: none; width: 530px;padding:0 5px;" />
			             	</label>
			             	<font color="red">*</font>
			             </td>
						</tr>			      		      			
								   					
				</table>		
		      <table width="100%" border="0" cellspacing="0" class="table">
		           	<tr class="tb-line">
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
					<tr class="tb-line">
			            <td class="tb-td line-submit" align="center" colspan="4">
			                <label class="tb-input-submit">		                
			                	<s:submit id="btnAdd" value="保  存" />								
							</label>
			                <label class="tb-input-submit">
								<input type="reset" value="取  消"/>
							</label>
							<label class="tb-input-submit">
								<input type="button" value="返回" onclick="history.back()"/>
							</label>
						</td>
					</tr>
            </table>
			</s:form>	
</body>
</html>
